<?php
include "conecta_pg.inc";
require '/usr/share/php/fpdf/fpdf.php';

function converte($string) {
	return iconv("UTF-8", "ISO-8859-1", $string);
}

$sql = "SELECT * FROM curriculo";
$resultado = pg_query ($sql);

// RELATORIO
$pdf = new FPDF("L", "pt", "A4");
$pdf->AddPage();
$pdf->Ln(30);

$pdf->SetFont("arial", "B", 18);
$pdf->Cell(0,5, converte("Relação de Currículos"),0,1,"C");
$pdf->Ln(20);

$pdf->SetFont("arial", "B", 12);
$pdf->Cell(47,20, converte("Código"),1,0,"C");
$pdf->Cell(200,20, converte("Nome do currículo"),1,0,"L");
$pdf->Cell(540,20, converte("Descrição"),1,1,"L");

$pdf->SetFont("arial", "", 10);

while ($linha = pg_fetch_array($resultado)) {
	$pdf->Cell(47,20,$linha["codigo_curriculo"],1,0,"C");
	$pdf->Cell(200,20, $linha["nome_curriculo"],1,0,"L");
	$pdf->Cell(540,20, converte($linha["descricao_curriculo"]),1,1,"L");
}

$pdf->Output("relatorio_curriculos.pdf", "I");
pg_close($conexao);
?>
